package com.wego.controller;

import com.wego.bean.TableBean;
import com.wego.common.bean.PageBean;
import com.wego.entity.domain.Cart;
import com.wego.entity.query.CartQuery;
import com.wego.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * (tb_cart)表控制层
 *
 * @author xxxxx
 */
@Controller
@RequestMapping("manager/cart")
public class CartController {

    @Autowired
    private CartService cartService;

    @GetMapping("/list")
    @ResponseBody
    public TableBean list(CartQuery cartQuery) {
        //构造动态查询条件
        PageBean<Cart> cartPageBean = cartService.selectPage(cartQuery);
        List<Cart> cart = cartPageBean.getResult();
        Long count = cartPageBean.getTotal();
        TableBean tableBean = new TableBean<Cart>();
        tableBean.setCode(0);
        tableBean.setMsg("");
        tableBean.setData(cart);
        tableBean.setCount(count);
        return tableBean;
    }

}
